from odoo import api, fields, models, _


class Rent(models.Model):
    _name = 'check.longrent'
    _description = "长租登记"
    _inherit = ['mail.thread', 'mail.activity.mixin']

    name = fields.Char(
        string="宾客姓名",
        required=True,
    )


    gender = fields.Selection(
        [
            ('0', '男'),
            ('1', '女'),
        ],
        "宾客性别",
         default="1",
    )

    age = fields.Integer(
        "宾客年龄",
    )

    Id_type = fields.Selection(
        [
            ('0', '身份证'),
            ('1', '港澳通行证')
        ],
        "证件类型", default='0'
    )

    Id_number = fields.Char(
        "证件编号", required=True)



    address = fields.Char(
        "宾客地址", required=True
    )


    tel = fields.Char(
        "联系电话", required=True
    )


    source = fields.Selection(
        [
            ('0', '湖北省'),
            ('1', '北京市')
         ],
      "宾客来源",  default='0'
    )

    company_title = fields.Char(
       "公司名称", required=True
    )


    company_address = fields.Char(
        "公司地址", required=True
    )


    guest_img = fields.Binary(
        "主客照片"
    )

    house_select = fields.Many2one(
        'check.house',
        '入住房间'
    )

    live_day = fields.Date(
        '入住日期',
        default=lambda s: fields.Date.today(),
    )

    billing_scheme = fields.Many2one(
        'check.scheme',
        string='计费方案',
    )

    pledge_cash = fields.Monetary(
        '需缴押金',
        'currency_id',
        readonly=True
    )
    currency_id = fields.Many2one('res.currency')  # price helper

    live_time = fields.Selection(
        [('{}'.format(i), i) for i in range(1, 100)]
        , string="预住时长", default="1"
    )

    total_receive = fields.Monetary(
        '应收总额',
        'currency_id',
    )

    currency_id = fields.Many2one(
        'res.currency',
        default=lambda self: self.env.user.company_id.currency_id,

    )  # price helper

    virtual_total = fields.Monetary(
        '实收总额',
        'currency_id'
    )
    currency_id = fields.Many2one(
        'res.currency',
        default=lambda self: self.env.user.company_id.currency_id,

    )  # price helper

    pay_way = fields.Selection(
        [
            ('0', '现金'),
            ('1', '支付宝'),
            ('2', '微信'),
            ('3', '银行卡')
        ],
        "支付方式",
        default='0'
    )
    note = fields.Char(
        "备注信息"
    )

    house_id = fields.Many2one(
        'check.house',
        string="进住房间",
        domain="[('Stage', '!=', 'False')]"
    )

    Stage = fields.Boolean(
        string="状态",
        related='house_id.Stage',
    )


